﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp17
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btn_Click(object sender, RoutedEventArgs e)
        {
            lbMessage.Items.Clear();
        }

        private void PreviewKey(object sender, KeyEventArgs e)
        {
            string str = $"{e.RoutedEvent};     key:{e.Key}";
            lbMessage.Items.Add(str);

            //true不向下传递
            e.Handled = true;
        }

        private void Label_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            string str = $"{e.RoutedEvent};     key:{e.RoutedEvent}  Text:{e.Text}";
            lbMessage.Items.Add(str);
        }

        private void txtType_TextChanged(object sender, TextChangedEventArgs e)
        {
            string str = $"{e.RoutedEvent};     key:{e.RoutedEvent}";
            lbMessage.Items.Add(str);
        }

        private void txtType_TextInput(object sender, TextCompositionEventArgs e)
        {
            string str = $"{e.RoutedEvent};     key:{e.RoutedEvent}  Text:{e.Text}";
            lbMessage.Items.Add(str);
        }
    }
}